<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // var str = 'hello小哥哥,hello小姐姐,Hello大叔'
      // var res = str.replace(/hello/gi,'你好')
      // console.log(res);

      var str = '<h1 title="你好">hello</h1>';
      var res = str.replace(/<|>|"/g, (abcd) => {
        if(abcd === '<') {
            return '&lt';
        }else if(abcd == '"') {
            return '&amp';
        }
      });

      console.log(res);
    </script>
  </body>
</html>
